package com.elong.businesstravel.modules.orders.view;

import com.elong.businesstravel.R;
import com.elong.businesstravel.base.BaseLinearLayout;
import com.elong.businesstravel.entitys.OrderInfo;

import android.content.Context;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 我的订单View
 * 
 * @author lenovo
 * 
 */
public class OrdersView extends BaseLinearLayout {

	public OrdersView(Context context) {
		super(context);
		init();
	}

	public OrdersView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	private void init() {
		LayoutInflater.from(mContext).inflate(R.layout.view_orders, this, true);

	}

	/**
	 * 设置订单号
	 * 
	 * @param ordersNumber
	 */
	public void setOrdersNumberTextView(String ordersNumber) {
		TextView ordersNumberTextView = (TextView) findViewById(R.id.ordersNumberTextView);
		if("0".equals(ordersNumber)){
			ordersNumberTextView.setText("待生成"	);
		}else{
		ordersNumberTextView.setText(ordersNumber);
		}
	}

	/**
	 * 设置订单状态
	 * 
	 * @param ordersStatus
	 */
	public void setOrdersStatusTextView(String ordersStatus) {
		TextView ordersStatusTextView = (TextView) findViewById(R.id.ordersStatusTextView);
		ordersStatusTextView.setText(ordersStatus);
	}

	/**
	 * 预定时间
	 * 
	 * @param timeString
	 */
	public void setTimeTextView(String timeString) {
		TextView timeTextView = (TextView) findViewById(R.id.timeTextView);
		timeTextView.setText(timeString);
	}

	/**
	 * 酒店名字地点
	 * 
	 * @param hotelName
	 */
	public void setHotelNameTextView(String hotelName,
			OnClickListener onClickListener) {
		TextView hotelNameTextView = (TextView) findViewById(R.id.hotelNameTextView);
		hotelNameTextView.setOnClickListener(onClickListener);
		hotelNameTextView.setText(hotelName);
	}

	/**
	 * 酒店价钱
	 * 
	 * @param hotelMoney
	 */
	public void setHotelMoneyTextView(SpannableStringBuilder hotelMoney) {
		TextView hotelMoneyTextView = (TextView) findViewById(R.id.hotelMoneyTextView);
		hotelMoneyTextView.setText(hotelMoney);
	}

	/**
	 * 房间类型
	 * 
	 * @param roomType
	 */
	public void setRoomTypeTextView(String roomType) {
		TextView roomTypeTextView = (TextView) findViewById(R.id.roomTypeTextView);
		roomTypeTextView.setText(roomType);
	}

	/**
	 * 房间数量
	 * 
	 * @param roomNum
	 */
	public void setRoomNumTextView(String roomNum) {
		TextView roomNumTextView = (TextView) findViewById(R.id.roomNumTextView);
		roomNumTextView.setText(roomNum);
	}

	/**
	 * 返的钱数
	 * 
	 * @param fanString
	 */
	public void fanMoneyTextView(String fanString) {
		ImageView fanImageView = (ImageView) findViewById(R.id.fanImageView);
		TextView fanMoneyTextView = (TextView) findViewById(R.id.fanMoneyTextView);
		if (TextUtils.isEmpty(fanString) || "0".equals(fanString)) {
			fanImageView.setVisibility(View.GONE);
			fanMoneyTextView.setVisibility(View.GONE);
		} else {
			fanImageView.setVisibility(View.VISIBLE);
			fanMoneyTextView.setVisibility(View.VISIBLE);
			fanMoneyTextView.setText(fanString);
		}
	}

	/**
	 * 酒店详细地址
	 * 
	 * @param hotelAddress
	 */
	public void setHotelAddressTextView(String hotelAddress) {
		TextView hotelAddressTextView = (TextView) findViewById(R.id.hotelAddressTextView);
		hotelAddressTextView.setText(hotelAddress);
	}

	/**
	 * 宾馆电话
	 * 
	 * @param hotelPhone
	 */
	public void setHotelPhoneTextView(String hotelPhone,
			OnClickListener onClickListener) {
		TextView hotelPhoneTextView = (TextView) findViewById(R.id.hotelPhoneTextView);
		hotelPhoneTextView.setText(hotelPhone);
		hotelPhoneTextView.setOnClickListener(onClickListener);
	}

	/**
	 * 定宾馆人姓名
	 * 
	 * @param nameString
	 */
	public void setNameTextView(String nameString) {
		TextView nameTextView = (TextView) findViewById(R.id.nameTextView);
		nameTextView.setText(nameString);
	}

	/**
	 * 联系人电话
	 * 
	 * @param namePhone
	 */
	public void setNamePhoneTextView(String namePhone) {
		TextView namePhoneTextView = (TextView) findViewById(R.id.namePhoneTextView);
		namePhoneTextView.setText(namePhone);
	}

	/**
	 * 入住时间
	 * 
	 * @param inTime
	 */
	public void setInTimeTextView(String inTime) {
		TextView checkInTimeTextView = (TextView) findViewById(R.id.checkInTimeTextView);
		checkInTimeTextView.setText(inTime);
	}

	/**
	 * 离店时间
	 * 
	 * @param outTime
	 */
	public void setOutTimeTextView(String outTime) {
		TextView outTimeTextView = (TextView) findViewById(R.id.outTimeTextView);
		outTimeTextView.setText(outTime);
	}

	/**
	 * 离店时间
	 * 
	 * @param reservedTo
	 */
	public void setReservedToTextView(String reservedTo) {
		TextView reservedToTextView = (TextView) findViewById(R.id.reservedToTextView);
		reservedToTextView.setText(reservedTo);
	}

	/**
	 * 取消订单
	 * 
	 * @param onClickListener
	 */
	public void setCancelOrderOnClickListener(OnClickListener onClickListener) {
		Button cancelOrdersButton = (Button) findViewById(R.id.cancelOrdersButton);
		cancelOrdersButton.setOnClickListener(onClickListener);

	}
	
	/**
	 * 录音评论点击事件
	 * @param onClickListener
	 */
	public void setCommentOnClickListener(OnClickListener onClickListener){
		Button commentRecordButton = (Button)findViewById(R.id.commentRecordButton);
		commentRecordButton.setOnClickListener(onClickListener);
	}
	
	public void setHotelMapButtonVisibility(int visibility){
		Button hotelMapButton = (Button) findViewById(R.id.hotelMapButton);
		hotelMapButton.setVisibility(visibility);
	}
	
	public Button getRecorderButton() {
		return (Button)findViewById(R.id.commentRecordButton);
	}
	
	public void setCommentVisibility(int visibility){
		Button commentRecordButton = (Button)findViewById(R.id.commentRecordButton);
		commentRecordButton.setVisibility(visibility);
	}

	public void setCancelOrderVisibility(int visibility) {
		ViewGroup cancelOrderLayout = (ViewGroup) findViewById(R.id.cancelOrderLayout);
		cancelOrderLayout.setVisibility(visibility);
		Button cancelOrdersButton = (Button) findViewById(R.id.cancelOrdersButton);
		cancelOrdersButton.setVisibility(visibility);
	}

	public void setNoticeLayoutVisibility(int visibility) {
		ViewGroup viewGroup = (ViewGroup) findViewById(R.id.noticeLayout);
		viewGroup.setVisibility(visibility);
	}

	public void setButtonLayoutVisibility(int visibility) {
		ViewGroup viewGroup = (ViewGroup) findViewById(R.id.buttonLayout);
		viewGroup.setVisibility(visibility);
	}

	public void setNoticeTextView(String notice) {
		TextView noticeTextView = (TextView) findViewById(R.id.noticeTextView);
		noticeTextView.setText(notice);
	}

	/**
	 * 查看位置
	 * 
	 * @param onClickListener
	 */
	public void setHotelMapOnClickListener(OnClickListener onClickListener) {
		Button hotelMapButton = (Button) findViewById(R.id.hotelMapButton);
		hotelMapButton.setOnClickListener(onClickListener);
	}

	/**
	 * 分享订单
	 * 
	 * @param onClickListener
	 */
	public void setShareOrderTextView(OnClickListener onClickListener) {
		TextView shareOrderTextView = (TextView) findViewById(R.id.shareOrderTextView);
		shareOrderTextView.setOnClickListener(onClickListener);
	}

	/**
	 * 分享位置
	 * 
	 * @param onClickListener
	 */
	public void setShareLocationTextView(OnClickListener onClickListener) {
		TextView shareLocationTextView = (TextView) findViewById(R.id.shareLocationTextView);
		shareLocationTextView.setOnClickListener(onClickListener);
	}
	
	public void setPlayRecordLayout(OnClickListener onClickListener){
		ViewGroup playRecordLayout = (ViewGroup) findViewById(R.id.playRecordLayout);
		playRecordLayout.setOnClickListener(onClickListener);
	}
	
	public void setRecordLenghtTextView(String lenght){
		TextView recordLenghtTextView = (TextView)findViewById(R.id.recordLenghtTextView);
		recordLenghtTextView.setText(lenght);
	}
	
	public void setPlayRecordLayoutVisibility(int visibility){
		ViewGroup playRecordLayout = (ViewGroup) findViewById(R.id.playRecordLayout);
		playRecordLayout.setVisibility(visibility);
	}
	
	public ImageView getPlayAnimImageView(){
		ImageView playAnimImageView = (ImageView)findViewById(R.id.playAnimImageView);
		return playAnimImageView;
	}
}
